Mounting Linux File Systems: Essential Steps for Beginners
Mounting in Linux is a crucial operation to connect external storage devices (such as hard drives and USB flash drives) to the directory structure, enabling the system to read data from external devices as if they were local files. Since Linux directories follow a tree structure, external devices must be attached to the system's directory tree through a mount point (an empty directory). **Core Concepts**: Device name (e.g., `/dev/sdb1`) and mount point (e.g., `/mnt/usb`). Before operation, confirm the device name using `lsblk` or `fdisk -l`, and create the mount point with `sudo mkdir`. **Mounting Steps**: 1. Execute `sudo mount [device name] [mount point]`; 2. Verify success with `df -h` or `mount`; 3. Unmount using `sudo umount [mount point]`, ensuring no programs are accessing the device. **Common Issues**: Non-existent mount points, incorrect device names, and "device busy" during unmounting. Solutions include creating the directory, confirming the device, and exiting programs using the device. Temporary mounts are not persistent across reboots; permanent mounts require modifying `/etc/fstab`. **Summary**: By mastering device names, mount points, and the `mount/umount` commands, combined with `lsblk` to verify devices, you can successfully mount and access external storage.
Read MoreLearn Linux Disk Partitioning and Mounting in 5 Minutes
Partitioning and mounting disks in Linux are fundamental operations for managing storage, analogous to closet organization and entry points. The steps are as follows: 1. **Check Disks**: Use `lsblk` or `sudo fdisk -l` to identify hard drives/partitions, and `df -h` to view currently mounted partitions. 2. **Create Partition**: Enter the tool with `sudo fdisk /dev/sdb`, input `n` to create a new primary partition, specify the size (e.g., `+20G`), and save with `w`. 3. **Format**: Format with `sudo mkfs.ext4 /dev/sdb1` (e.g., using the ext4 filesystem). **Always back up data before formatting**. 4. **Temporary Mount**: Create a mount point with `sudo mkdir /mnt/mynewdisk`, then mount with `sudo mount /dev/sdb1 /mnt/mynewdisk`. 5. **Permanent Mount**: Use `sudo blkid` to get the UUID, edit `/etc/fstab` to add an entry (format: `UUID=... 挂载点 ext4 defaults 0 0`), and verify with `sudo mount -a`. Key points: Partition → Format → Mount → Persistence. Back up data before operations, and use `umount` for unmounting.
Read More